package com.amit.Basic_Simple_Program;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Check_Frequency_In_Collection {

	public static void main(String[] args) {
		
		
		ArrayList al=new ArrayList();
		
		al.add("a");
		al.add("a");
		al.add("b");
		al.add("a");
		al.add("c");
		al.add(1, "h");
		System.out.println(al.get(4));
		System.out.println(al.indexOf("b"));
		
		List list=al.subList(1, 3);
		System.out.println(list);
		
		
		
		int i=Collections.frequency(al, "a");
		
		System.out.println("a"+" "+"came" +" "+i);
		
		Set<String> uniqueSet = new HashSet<String>(al);
		
		for (String temp : uniqueSet) {
			System.out.println(temp + ": " + Collections.frequency(al, temp));
			
		}
		
		
		
	
	}

}
